package thread.demo.queue;

import java.util.concurrent.ArrayBlockingQueue;

public class ArrayBlockingQueue_Take {
  public static void main(String[] args) throws InterruptedException {
    ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<>(2);
    queue.add(1);
    queue.add(2);
    
    System.out.println(queue.take());
    System.out.println(queue.take());
    
    // 如果没有元素的话，直接挂起
    System.out.println(queue.take());
  }
}
